package leetcode;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * ClassName: XiaoMei
 * Package: leetcode
 * Description:
 *
 * @Author wjn
 * @Create 2025/8/23 10:21
 * @Version 1.0
 */
public class XiaoMei {
    public static void main(String[] args) throws IOException {
        Scanner  scanner = new Scanner(System.in);
        int T = scanner.nextInt();

        while (T-- > 0){
            int x = scanner.nextInt();
            List<Integer> list = new ArrayList<>();
            list.add(x);
            for (int i = 0; i < 20; i++){
                if((x & (1 << i))== 0) {
                    list.add(x | (1 << i));
                }
            }
            System.out.println(list.size());
            for (int i = 0; i < list.size(); i++){
                System.out.print(list.get(i));
                if ( i < list.size() - 1) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}
